package com.shenhaofeng.app.download;


/**
 * Created by Administrator on 2016/9/14.
 */
public class RequestBuilder {

    private String mUrl;

    private String mFileName;

    private String mMime;


    /**
     * 设置文件下载链接地址
     *
     * @param url
     * @return
     */
    public RequestBuilder url(String url) {
        this.mUrl = url;
        return this;
    }


    /**
     * 保存到本地的文件名,可以不设置
     *
     * @param name
     * @return
     */
    public RequestBuilder fileName(String name) {
        this.mFileName = name;
        return this;
    }


    /**
     * 构建下载请求对象
     *
     * @return
     */
    public DownloadRequest build() {
        DownloadRequest request = new DownloadRequest();
        request.url = mUrl;
        request.fileName = mFileName==null?mUrl.substring(mUrl.lastIndexOf("/"),mUrl.length()).replace("/",""):mFileName;
        return request;
    }


}
